﻿<cfsilent>
	<cfscript>
	
		event.setArg("pageTitle", "教学运行基础数据 - 培养方案修订 - 专业方向课程");

		sql = "SELECT 
					sbj_id, sbj_name 
				FROM 
					t_subject 
				WHERE 
					sbj_id = :subjectId  " ;
					
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="subjectId", value=event.getArg("SubID"), cfsqltype="cf_sql_varchar" );
		
		rs_subjectEntity = queryObj.execute( sql=sql ).getResult();

		sql = "SELECT 
					sbj_id, sbj_name 
				FROM 
					t_subject 
				WHERE 
					sbj_id LIKE :parent 
				ORDER BY 
					sbj_id ASC " ;
					
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="parent", value=rs_subjectEntity.sbj_id & '_', cfsqltype="cf_sql_varchar" );
		
		rs_dir = queryObj.execute( sql=sql ).getResult();

		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");
		
		/* 初始化学期参数 */
		if ( not event.isArgDefined("Dir") and rs_dir.recordCount ) {
			event.setArg("Dir", rs_dir["sbj_id"][1]);
		}

		targetArgs = structNew();
		structInsert(targetArgs, "SubID", event.getArg("SubID"), true);
		structInsert(targetArgs, "Edition", event.getArg("Edition"), true);
		structInsert(targetArgs, "Schema", event.getArg("Schema"), true);

		currentTab = event.getArg("TabID", "labDir" & event.getArg("Dir") );

		passArgs = structNew();
		structInsert(passArgs, "SubID", event.getArg("SubID"), true);
		structInsert(passArgs, "Edition", event.getArg("Edition"), true);
		structInsert(passArgs, "Schema", event.getArg("Schema"), true);

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('programSchema')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">培养方案</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 edit"></i>培养方案修订 - <cfoutput>#rs_subjectEntity.sbj_name#</cfoutput>专业(<cfoutput>#event.getArg("Edition")#</cfoutput>)版
				</h2>
			</div>
		</div>
	</div>
</div>

<!--- 加载导航菜单 --->
<!-- stepMenu-->
<cfoutput>#event.getArg("stepMenu")#</cfoutput>
<!--/stepMenu-->

<div class="UIElement">
	<ul class="senateFirstPage">
		<cfif rs_dir.recordCount eq 0>
			<li>
				<div class="clearfix" id="summary">
					
					<div class="systemNotice">
						<h3><span class="img icon16x16 subject"></span>该专业没有设置主修方向</h3>
						<p>您需要首先设置特定专业的主修方向, 才能修订培养方案中该方向的特定课程. </p>
					</div>
					
				</div>
			</li>
			<cfelse>
			<li>
				<div class="clearfix" id="summary">
					<div class="UItab2">
						<div class="tabLables">
                            <cfloop query="rs_dir">
								<cfset structInsert(targetArgs, "Dir", rs_dir.sbj_id, true) />
								<a <cfif currentTab eq "labDir"&rs_dir.sbj_id>class="active"</cfif> href="<cfoutput>#buildURL('programSchemaWizardDirection', targetArgs)#</cfoutput>"><cfoutput>#rs_dir.sbj_name#</cfoutput></a>
							</cfloop>
							<cfset structDelete(targetArgs, "Dir") />
						</div>
					</div>
					
					<div class="tabContentBox">
						
						<cfset structInsert(targetArgs, "Dir", event.getArg("Dir"), true) />
						
						<div class="noticeBlock">
							<div class="operation">
								<a class="uiButton " href="<cfoutput>#buildURL('programSchemaWizardCreateDirectionEntity', targetArgs)#</cfoutput>"><i class="mrs img btnAdd"></i><span class="uiButtonText">设置新课程</span></a>
							</div>
							<h3>专业方向课程开设情况</h3>
							<p><span class="img icon16x16 message"></span>如果您需要设置新的课程信息, 请通过上方的 "设置新课程" 按钮添加学期课程信息.</p>
						</div>
						
						<!--- 专业方向课程 --->
                          
						 <cfset sql = "SELECT 
											term_index 
										FROM 
											t_schema 
										WHERE 
											grade = :grade 
											AND 
											sbj_id = :subjectDir 
										GROUP BY 
											term_index 
										ORDER BY 
											term_index  " />
                                            
                        <cfset queryObj = new query( datasource=application.dnsSlave ) />
                        <cfset queryObj.addParam( name="grade", value=event.getArg("Edition"), cfsqltype="cf_sql_char" ) />
                        <cfset queryObj.addParam( name="subjectDir", value=event.getArg("Dir"), cfsqltype="cf_sql_varchar" ) />
                        
                        <cfset rs_term = queryObj.execute( sql=sql ).getResult() />
                        
                        <cfloop query="rs_term">

							<cfset sql = "SELECT 
											  t_course.course_name,
											  t_course.course_credit, 
											  t_institute.institute_short, 
											  t_course_prop.prop_name, 
											  t_course_nature.cna_name, 
											  t_course.period_theory, 
											  t_course.period_practice, 
											  t_course.period_computer, 
											  t_schema.shm_id, 
											  t_course_prop.prop_id, 
											  t_course.course_code 
										  FROM 
											  t_schema 
											  INNER JOIN t_course ON t_course.cid = t_schema.cid 
											  INNER JOIN t_institute ON t_course.institute_id = t_institute.institute_id 
											  INNER JOIN t_course_prop ON t_course_prop.prop_id = t_schema.prop_id 
											  INNER JOIN t_course_nature ON t_course_nature.cna_id = t_schema.cna_id 
										  WHERE 
											  t_schema.grade = :grade 
											  AND 
											  t_schema.sbj_id = :subjectId 
											  AND 
											  t_schema.term_index = :term 
										  ORDER BY 
											  t_course_nature.cna_name, t_course_prop.prop_name, t_course.course_name " />
                                              
							<cfset queryObj = new query( datasource=application.dnsSlave ) />
							<cfset queryObj.addParam( name="term", value=rs_term.term_index, cfsqltype="cf_sql_char" ) />
							<cfset queryObj.addParam( name="grade", value=event.getArg("Edition"), cfsqltype="cf_sql_char" ) />
							<cfset queryObj.addParam( name="subjectId", value=event.getArg("Dir"), cfsqltype="cf_sql_varchar" ) />
                            
							<cfset rs_schema = queryObj.execute( sql=sql ).getResult() />
							
							<cfset row = 0 />
						
							<table class="UItable">
								<tr>
									<td align="center" width="22" class="cellBorder"><cfoutput>#mathAdvice.convertTermIdxToChinese(rs_term.term_index)#</cfoutput></td>
									<td align="center" class="cellBorder">
										<cfif rs_schema.recordCount>
											<table class="UIEditable">
												<thead>
													<tr>
														<td width="48">类别</td>
														<td width="48">课程性质</td>
														<td width="80">课程号</td>
														<td align="left">课程</td>
														<td width="24" align="right">理论</td>
														<td width="24" align="right">实践</td>
														<td width="24" align="right">上机</td>
														<td width="24" align="right">学分</td>
														<td width="48">开课学院</td>
														<td width="18"></td>
													</tr>
												</thead>
												<tbody>
                                                    <cfloop query="rs_schema">
														<cfset structInsert(passArgs, "ID", rs_schema.shm_id, true) />
														<cfset row++ />
														<tr class="editRows">
															<td><cfoutput>#rs_schema.cna_name#</cfoutput></td>
															<td><cfoutput>#rs_schema.prop_name#</cfoutput></td>
															<td><span class="numeric"><cfoutput>#rs_schema.course_code#</cfoutput></span></td>
															<td align="left"><span class="notice"><cfif rs_schema.prop_id eq '1'>※</cfif></span><cfoutput>#rs_schema.course_name#</cfoutput></td>
															<td align="right"><cfif rs_schema.period_theory gt 0><span class="numeric"><cfoutput>#rs_schema.period_theory#</cfoutput></span></cfif></td>
															<td align="right"><cfif rs_schema.period_practice gt 0><span class="numeric"><cfoutput>#rs_schema.period_practice#</cfoutput></span></cfif></td>
															<td align="right"><cfif rs_schema.period_computer gt 0><span class="numeric"><cfoutput>#rs_schema.period_computer#</cfoutput></span></cfif></td>
															<td align="right"><span class="numeric"><cfoutput>#numberFormat(rs_schema.course_credit,'_._')#</cfoutput></span></td>
															<td align="right"><cfoutput>#rs_schema.institute_short#</cfoutput></td>
															<td><a class="operation" href="<cfoutput>#buildURL('programSchemaWizardModifyDirectionEntity', passArgs)#</cfoutput>"></a></td>
														</tr>
													</cfloop>
												</tbody>
											</table>
										</cfif>
									</td>
								</tr>
							</table>
						
						</cfloop>
					</div>
					
				</div>
			</li>
		</cfif>
	</ul>
</div>





